home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / System7 tools / AppleScript / Sample Scripts / Numerics / Round Off Example next >
Encoding:
Text File  |  1993-04-07  |  630 b   |  11 lines  |  [TEXT/ToyS]

  1. set x to (("9776.552" as real) as string) -- string to real to string
  2. -- the previous line shows how the number changes as it is coerced to a real
  3. set y to "9776.552"  -- this is the original string
  4. 9776.552 -- watch this when you compile it!  It no longer is 9776.552
  5. -- the following displays values in the result window
  6. -- x is the converted string, y is the original string
  7. -- x = y is a string comparision, while the next one is a pair of reals
  8. -- Finally, an example of how two numbers which don't suffer from round off
  9. -- can equal one that does
  10. {x, y, x = y, (x as real) = (y as real), 76.552 + 9700 = 9776.5519999999997}
  11.